package Java.Array;

public class Demo01 {
    public static void main(String[] args) {
     int[] arrays = new int[10];
     for (int i = 0; i < arrays.length; i++) {
         arrays[i] = i;
     }
    //打印全部数组元素
        for (int i = 0; i < arrays.length; i++) {
            System.out.println(arrays[i]);
        }

//    计算所有元素的和
        int sums=0;
        for (int i = 0; i < arrays.length; i++) {
            sums += arrays[i];
        }
        System.out.println("sums="+sums);
//        查找最大元素
        int max = arrays[0];
        for (int i = 0; i < arrays.length; i++) {
            if(max<arrays[i]){
                max=arrays[i];
            }
        }
        System.out.println("max="+max);
    }
}
